<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>{$lang.title}</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link rel="shortcut icon" href="/static/images/ico.jpg" media="screen" />
		<link href="/static/plugin/ace/css/bootstrap.min.css" rel="stylesheet" />
		<!-- ace styles -->
		<link rel="stylesheet" href="/static/plugin/ace/css/ace.min.css" />
		<link rel="stylesheet" href="/static/plugin/ace/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="/static/plugin/ace/css/ace-skins.min.css" />
		<link rel="stylesheet" href="/static/plugin/ace/css/font-awesome.min.css" />
		<!--[if IE 7]>
		<link rel="stylesheet" href="/static/plugin/ace/css/font-awesome-ie7.min.css" />
		<![endif]-->
		<link rel="stylesheet" href="/static/plugin/ace/font/fontawesome-webfont.woff" />
		<style>
			.yui_center{
				margin-top: 100px;
			}
		</style>
		<link href="/static/plugin/layer/theme/default/layer.css">
		<script src="/static/js/jquery.min.js"></script>
		<script src="/static/plugin/layer/layer.js"></script>
		<script src="/static/plugin/layui/layui.js"></script>
	</head>

	<body class="login-layout">
		<div class="main-container">
			<div class="main-content">

				<div class="row">

					<div style="position: absolute;right: 30px;top: 20px;">
						<foreach name="lang_list" item="name" key="code">
							<dd style="margin: 15px"><a href="" onclick="switchLang('{$code}');return false;">{$name}</a></dd>
						</foreach>
					</div>

					<div class="col-sm-10 col-sm-offset-1" style="margin-top: 60px">
						<div class="login-container">
							<div class="center yui_center">
								<h1>
									<i class="green"></i>
									<span class="red">{$lang.login_red_fir}</span>
									<span class="white">{$lang.login_white_sed}</span>
								</h1>
								<h4 class="blue">{$lang.login_motto}</h4>
							</div>

							<div class="space-6"></div>

							<div class="position-relative">
								<div id="login-box" class="login-box visible widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header blue lighter bigger">
												<i class="icon-globe green"></i>
												{$lang.login_title}
											</h4>

											<div class="space-6"></div>

											<form>
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input name="username" type="text" class="form-control" placeholder="{$lang.login_user_notice}" value="{$username}"/>
															<i class="icon-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input name="password" type="password" class="form-control" placeholder="{$lang.login_pwd_notice}" value="{$password}"/>
															<i class="icon-lock"></i>
														</span>
													</label>

													<div class="space"></div>

													<div class="clearfix">
														<label class="inline">
															<eq name="rember" value='1'>
																<input type="checkbox" name="rember" class="ace" checked/>
																<else/>
																<input type="checkbox" name="rember" class="ace" />
															</eq>
															<span class="lbl"> {$lang.login_rember}</span>
														</label>

														<button id="yui_submit" type="button" class="width-35 pull-right btn btn-sm btn-primary">
															<i class="icon-key"></i>
															{$lang.login_button}
														</button>
													</div>

													<div class="space-4"></div>
												</fieldset>
											</form>

										</div><!-- /widget-main -->

										<div class="toolbar clearfix" >
											<div>
												<a href="#" onclick="show_box('forgot-box'); return false;" class="forgot-password-link">
													<i class="icon-arrow-left"></i>
													{$lang.login_forget_pwd}
												</a>
											</div>

											<div style="display: none">
												<a href="#" onclick="show_box('signup-box'); return false;" class="user-signup-link">
													I want to register
													<i class="icon-arrow-right"></i>
												</a>
											</div>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /login-box -->

								<div id="forgot-box" class="forgot-box widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header red lighter bigger">
												<i class="icon-key"></i>
												{$lang.login_retrieve_pwd}
											</h4>

											<div class="space-6"></div>
											<p>
												{$lang.login_retrieve_title}
											</p>

											<form>
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="email" class="form-control" placeholder="Email" />
															<i class="icon-envelope"></i>
														</span>
													</label>

													<div class="clearfix">
														<button type="button" class="width-35 pull-right btn btn-sm btn-danger">
															<i class="icon-lightbulb"></i>
															{$lang.login_retrieve_send}
														</button>
													</div>
												</fieldset>
											</form>
										</div><!-- /widget-main -->

										<div class="toolbar center">
											<a href="#" onclick="show_box('login-box'); return false;" class="back-to-login-link">
												{$lang.login_back2_login}
												<i class="icon-arrow-right"></i>
											</a>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /forgot-box -->

								<div id="signup-box" class="signup-box widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header green lighter bigger">
												<i class="icon-group blue"></i>
												New User Registration
											</h4>

											<div class="space-6"></div>
											<p> Enter your details to begin: </p>

											<form>
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="email" class="form-control" placeholder="Email" />
															<i class="icon-envelope"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" class="form-control" placeholder="Username" />
															<i class="icon-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="Password" />
															<i class="icon-lock"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="Repeat password" />
															<i class="icon-retweet"></i>
														</span>
													</label>

													<label class="block">
														<input type="checkbox" class="ace" />
														<span class="lbl">
															I accept the
															<a href="#">User Agreement</a>
														</span>
													</label>

													<div class="space-24"></div>

													<div class="clearfix">
														<button type="reset" class="width-30 pull-left btn btn-sm">
															<i class="icon-refresh"></i>
															Reset
														</button>

														<button type="button" class="width-65 pull-right btn btn-sm btn-success">
															Register
															<i class="icon-arrow-right icon-on-right"></i>
														</button>
													</div>
												</fieldset>
											</form>
										</div>

										<div class="toolbar center">
											<a href="#" onclick="show_box('login-box'); return false;" class="back-to-login-link">
												<i class="icon-arrow-left"></i>
												Back to login
											</a>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /signup-box -->
							</div><!-- /position-relative -->
						</div>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div>
		</div><!-- /.main-container -->
	</body>

	<script type="text/javascript">
        function show_box(id) {
            $('.widget-box.visible').removeClass('visible');
            $('#'+id).addClass('visible');
        }

        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                $('#yui_submit').click();
            }
        });

        //切换语言
        function switchLang(code) {
            $.post("/switchLang",
                {code:code},
                function(data,status){
                    if (data['code']==1){
                        location.reload();
                    }else{
                        layer.msg(data['msg']);
                    }
                }, "json"
            );
        }

        $(function () {

            $('#yui_submit').on('click', function () {
				var username = $("input[name='username']").val();
                var password = $("input[name='password']").val();
                var rember = $("input[name='rember']").is(':checked');
                if (username==''||password=='')
                    layer.msg('账户密码不能为空', {time:1000});
                else{
                    $.post("/login",
                        {
                            username:username,
                            password:password,
                            rember:rember
                        },
                        function(data,status){
                            layer.msg(data['msg']);
							if (data['code']==1){
                                window.location.href='/index';
							}
                        }, "json"
                    );
				}
            });
        })
	</script>

</html>
